package com.gaga.metadata.function.base;

import com.gaga.metadata.common.enums.DbOperatorType;
import com.gaga.metadata.common.enums.SqlFunctionType;
import com.gaga.metadata.entity.database.DataBaseColumn;
import com.gaga.metadata.entity.database.DataBaseFilter;
import com.gaga.metadata.function.AbstractFunctionProvider;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author liujia
 * @version 1.0
 * @date 2023/1/13 12:51
 */
public class SumFunctionProvider extends AbstractFunctionProvider<DataBaseFilter, DataBaseColumn> {

    @Override
    public List<DataBaseFilter> handler(DataBaseColumn dataBaseColumn) {

        List<DataBaseFilter> filters = new ArrayList<>(Arrays.asList(
                getFunctionFilter(new DataBaseFilter(), SqlFunctionType.SUM),
                getSymbolFilter(new DataBaseFilter(), DbOperatorType.LEFTBRACKET)
        ));
        filters.addAll(new ArrayList<>(Arrays.asList(
                getColumnFilter(new DataBaseFilter(), dataBaseColumn),
                getSymbolFilter(new DataBaseFilter(), DbOperatorType.RIGHTBRACKET)
        )));

        return filters;
    }
}
